// pages/pay/pay.js
Page({
  data: {
    Address:{},
    chekedCart:[],
    account:0,
    num:0
  },
  onLoad: function (options) {
    this.getAddress();
    this.getChekedCart();
    this.calculate();
  },
  getAddress(){
    const Address =  wx.getStorageSync("address");
    this.setData({Address});
  },
  getChekedCart(){
    const cart = wx.getStorageSync("cart") || [];
    const chekedCart = cart.filter(item=>item.checked);
    this.setData({chekedCart});
  },
  calculate(){
    let sum = 0, num = 0;
    this.data.chekedCart.forEach(item => {
      sum += item.goods_price * item.num;
      num += item.num;
    });
    this.setData({account:sum,num:num});
  },
  handlePay(){
    console.log('支付');
    wx.requestPayment({
      timeStamp: '',
      nonceStr: '',
      package: '',
      signType: 'MD5',
      paySign: '',
      success (res) { },
      fail (res) { }
    })
  }
})